package cn.hacynn.nd.pojo.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;


import java.io.Serializable;
import java.security.Principal;
import java.util.Collection;
import java.util.Date;

@TableName("user")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
//@JsonIgnoreProperties({"bucketName, safeCode"})
public class User implements Serializable, Principal {
    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @TableField()
    private String name;

    @TableField()
    private String account;

    @TableField()
    private String password;

    @TableField()
    private String email;

    // 填充策略——插入时填充
    @TableField(fill= FieldFill.INSERT, updateStrategy = FieldStrategy.NOT_NULL )
    private Date createTime;

    // 填充策略——插入和更新时填充
    @TableField(fill= FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @TableField("deleted")
    private Boolean deleted = false;

    @TableField
    private String bucketName;

    @TableField
    private String avator;

    @TableField("safe_on")
    private Boolean isSafeOn;

    @TableField("safe_code")
    private String safeCode;

    //FieldFill.UPDATE（更新时填充）和 FieldFill.INSERT_UPDATE（插入和更新时均填充）。
    @TableField(value = "last_login_time", fill= FieldFill.INSERT)
    private Date lastLoginTime;

    @TableField("total_space")
    private Long totalSpace;

    /**
     * 格式化日期
     */
    @TableField(exist = false)
    private String lastLoginTimeStr;

    @TableField(exist = false)
    private String createTimeStr;
//    @Override
//    public Collection<? extends GrantedAuthority> getAuthorities() {
//        return null;
//    }
//
//    @Override
//    public String getUsername() {
//        return getAccount();
//    }
//
//    @Override
//    public boolean isAccountNonExpired() {
//        return true;
//    }
//
//    @Override
//    public boolean isAccountNonLocked() {
//        return true;
//    }
//
//    @Override
//    public boolean isCredentialsNonExpired() {
//        return true;
//    }
//
//    @Override
//    public boolean isEnabled() {
//        return !isDeleted();
//    }
}

